home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
xygraf.zip
/
GRAF.VEC
< prev
next >
Wrap
Text File
|
1995-03-02
|
9KB
|
232 lines
shifts[20]; ' We suppose to use this array for shifts with bar grafs
xar[5];
yar[5];
dar[5];
tar[6];
for i = 1 to 5
xar[i] = i
yar[i] = i^2 - 10
dar[i] = i^2 / 2
tar[i] = lg(i) * 200 ' Tick, Manual
next
tar[6] = lg(6) * 200
grafclip(30, 10, 200, 200) ' Set area on screen
'Calc. scale (X - 0, Y = 1),
'First dataset (1) or not first (0), if first, all previous settings are
'ignored. Example: previous scale was -1 to 1, array elements have values in
'the range from -2 to 0. With first == 1, new scale will be from -2 to 2,
'and if first == 0 it will be from -2 to 1.
'Resize factor. If == 0 nothing happens. If < 0 every next call to this
'function resize scale to fit bar graf data. If > 0 - axe will be adjusted
marker_size(8) ' Do it before call to calc_scale in the case of bar graf
calc_scale(xar, 0, 1, -1)
calc_scale(dar, 1, 1, -1) ' y-scale, first, resize
calc_scale(yar, 1, 0, -1) ' y-scale, not first, resize
calc_scale(yar, 1, 0, 1) ' and fit to nice-looking scale
color(12) : style(1, 3) : fill(1)
'which, text dir, tick no (-1 for auto), s_tick no<,tick_ar, s_tick_arr>
'if auto (tick_no == -1) then number of sub ticks = s_tick_no * tick no
'in this case tick_no will be 5, sub_tick_no 25
'Manual ticks setup for X:
set_axe(1, 1, -1, 5, tar, tar, "One", "Two", "Three", "Four", "Five", "Six")
'Auto setup for Y:
set_axe(2, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(14, 9, 1, 2, 3, 1, 1 + 2) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
color(14) : style(5, 11) : fill(1)
cross() ' Draw beginning of axes (0,0)
PLOT(xar, dar, 4, 1, shifts) ' Plot second dataset
color(15) : style(6, 14)
PLOT(xar, yar, 4, 1, shifts) ' Plot second dataset
marker_size(4)
color(9) : style(1, 7)
PLOT(xar, yar, 3, 1, shifts) ' Plot data
marker_size(8)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
for i = 1 to 20
shifts[i] = 0
next
for i = 1 to 5
yar[i] = i^2 - 10
dar[i] = i^2 / 2 - 5
next
' In the next example we can use manual scale set, and do not fit with
' the second dataset.
grafclip(230, 20, 380, 210) ' Rectangle on screen
'grafscale(1, -10, 5, 15) ' Manual set of scale, instead of calc_scale()
calc_scale(xar, 0, 1, 0)
calc_scale(dar, 1, 1, -1) ' y-scale, first, resize
calc_scale(yar, 1, 0, -1) ' y-scale, not first, resize
calc_scale(yar, 1, 0, 1)
calc_scale(xar, 0, 0, 1)
set_axe(1, 0, -1, 2)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 5)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(14, 12, 0, 7, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
color(11) : style(1, 3)
cross() ' Draw beginning of axes (0,0)
PLOT(xar, yar, 5, 1, shifts) ' Plot dataset
color(8) : style(1, 2)
PLOT(xar, dar, 5, 1, shifts) ' Plot second dataset
for i = 1 to 20
shifts[i] = 0
next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rar[100];
sar[100];
for i = 1 to 100
rar[i] = i
sar[i] = sin(3.6 * i)
next
grafclip(420, 20, 600, 210) ' Clip rectangle on screen
grafscale(0, -1, 100, 2) 'Manual scale ajustment
'calc_scale(rar, 0, 0, 1) ' x-scale, not first, resize
'calc_scale(sar, 1, 0, 1) ' y-scale, not first, no resize
'calc_scale(sar, 1, 1, 1) ' and fit to nice-looking scale
set_axe(1, 0, -1, 2)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 2)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(14, 12, 3, 7, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
cross() ' (0, 0)
color(10) : style(1, 2) : setline(3, 0)
PLOT(rar, sar, 1, 1, shifts) ' Plot dataset
for i = 1 to 20
shifts[i] = 0
next
setline(1, 1)
''''''''''''''''''''''''''''''''' Add small graph at the corner of big one
'''''''''''''''''''''''''''''''''
grafclip(510, 35, 595, 90) ' Clip rectangle on screen
style(1, 0) : fill(1)
rectangle(480, 20, 600, 120)
calc_scale(rar, 0, 1, 0) ' x-scale, first, resize
calc_scale(sar, 1, 1, 0) ' y-scale, first, no resize
'calc_scale(sar, 1, 0, 1) ' and fit to nice-looking scale
set_axe(1, 1, -1, 0)
set_axe(2, 0, -1, 0)
'set_axe(4, 1, -1, 0)
'set_axe(8, 0, -1, 0)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(14, 12, 3, 7, 3, 1, 1 + 2) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
cross() ' (0, 0)
color(10) : style(1, 2) : setline(3, 0)
PLOT(rar, sar, 1, 1, shifts) ' Plot dataset
for i = 1 to 20
shifts[i] = 0
next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
marker_size(16)
zar[20];
' We set zar[] manually. The rules are:
' zar[4*i+1] keep ystart < 0;
' zar[4*i+2] keep ystart >= 0;
' zar[4*i+3] keep yend < 0;
' zar[4*i+4] keep yend >= 0;
zar[1] = 0 : zar[2] = 0 : zar[3] = 0 : zar[4] = 10
zar[5] = 0 : zar[6] = 0 : zar[7] = 0 : zar[8] = 24
zar[9] = 0 : zar[10] = 0 : zar[11] = 0 : zar[12] = 15
zar[13] = 0 : zar[14] = 0 : zar[15] = 0 : zar[16] = 10
zar[17] = 0 : zar[18] = 0 : zar[19] = 0 : zar[20] = 5
aar[20];
aar[1] = 0 : aar[2] = 10 : aar[3] = 0 : aar[4] = 12
aar[5] = 0 : aar[6] = 24 : aar[7] = 0 : aar[8] = 25
aar[9] = 0 : aar[10] = 15 : aar[11] = 0 : aar[12] = 25
aar[13] = 0 : aar[14] = 10 : aar[15] = 0 : aar[16] = 15
aar[17] = 0 : aar[18] = 5 : aar[19] = 0 : aar[20] = 7
grafclip(20, 250, 240, 420)
calc_scale(xar, 0, 1, 0) ' x-scale, first, no resize
calc_scale(zar, 1, 1, 0) ' y-scale, first, resize
calc_scale(aar, 1, 0, -1) ' y-scale, not first, no resize
' That is not necessary to resize
get_axes_dim(xmin, ymin, xmax, ymax)
grafscale(xmin, ymin * 1.2, xmax, ymax * 1.2)
calc_scale(xar, 0, 0, 1)
set_axe(1, 0, -1, 5)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 5)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(14, 12, 0, 7, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
color(8) : style(1, 2)
cross() ' Stacked Graf twice
PLOT(xar, zar, 6, 3)
color(14) : style(1, 9)
PLOT(xar, aar, 6, 3)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Now we combine manual and automatic approaches: first two arrays are
' composed manually, third is added with call to get_stacked()
' zar[4*i+1] keep ystart < 0;
' zar[4*i+2] keep ystart >= 0;
' zar[4*i+3] keep yend < 0;
' zar[4*i+4] keep yend >= 0;
grafclip(310, 250, 550, 450)
bar[20];
bar[1] = 0 : bar[2] = 0 : bar[3] = -10 : bar[4] = 10
bar[5] = 0 : bar[6] = 0 : bar[7] = -20 : bar[8] = 10
bar[9] = 0 : bar[10] = 0 : bar[11] = 0 : bar[12] = 10
bar[13] = 0 : bar[14] = 0 : bar[15] = 0 : bar[16] = 20
bar[17] = 0 : bar[18] = 0 : bar[19] = 0 : bar[20] = 2
car[20];
car[1] = -10 : car[2] = 10 : car[3] = -15 : car[4] = 20
car[5] = -20 : car[6] = 10 : car[7] = -25 : car[8] = 15
car[9] = 0 : car[10] = 10 : car[11] = 0 : car[12] = 17
car[13] = 0 : car[14] = 20 : car[15] = 0 : car[16] = 22
car[17] = 0 : car[18] = 2 : car[19] = 0 : car[20] = 12
color(9) : style(1, 1)
ear[20];
for i = 1 to 20
ear[i] = car[i]
next
calc_scale(xar, 0, 1, 0) ' x-scale, first, no resize
get_stacked(xar, ear) ' ear scale is enought
calc_scale(ear, 1, 0, -1) ' y-scale, first, resize
get_axes_dim(xmin, ymin, xmax, ymax)
grafscale(xmin, ymin * 1.2, xmax, ymax * 1.2)
calc_scale(xar, 0, 0, 1)
calc_scale(ear, 1, 0, 1)
set_axe(1, 0, -1, 5)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 5)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(14, 12, 0, 7, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
cross()
color(9) : style(1, 1)
PLOT(xar, bar, 6, 3)
color(11) : style(1, 6)
PLOT(xar, car, 6, 3)
color(10) : style(1, 12)
PLOT(xar, ear, 6, 3)
END